#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 55;
const int M = 1e9 + 7;

int t, n;
string s;

char res[N][N];

// i胜j
void win(int i, int j) {
    res[i][j] = '+', res[j][i] = '-';
}

void draw(int i, int j) {
    res[i][j] = res[j][i] = '=';
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> t;
    while (t--) {
        cin >> n >> s;
        vector<int> b;
        for (int i = 0; i < n; i++)
            if (s[i] == '2')
                b.push_back(i + 1);


        int cntb = b.size();

        if (cntb == 1 || cntb == 2) {
            cout << "NO" << endl;
            continue;
        }

        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                if (i == j)
                    res[i][j] = 'X';

                else {
                    if (s[i - 1] == '2' && s[j - 1] == '2') {
                        int pi = -1, pj = -1;
                        for (int k = 0; k < cntb; k++) {
                            if (b[k] == i) pi = k;
                            if (b[k] == j) pj = k;
                        }

                        // ij相邻 i胜j
                        if (pj - pi == 1) win(i, j);
                        else if (pi == 0 && pj == cntb - 1) win(j, i);
                        else draw(i, j);
                    }
                    else {
                        draw(i, j);
                    }
                }
            }
        }

        cout << "YES" << endl;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                cout << res[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}